#encoding:utf-8

class SolutionOfEqu:
    def __init__(self):
        pass

    def input_(self):
        print('请依次输入一元二次方程的三个参数a，b，c :')

        self.a = float(input('a:'))
        self.b = float(input('b:'))
        self.c = float(input('c:'))
        print('a =', self.a, '\nb =', self.b, '\nc =', self.c)
        print("一元二次方程为：{}x² + {}x + {:.0f} = 0".format(" " if self.a==1 else self.a ," " if self.b==1 else self.b,self.c))

    def quadratic(self):

        delta = self.b * self.b - 4 * self.a * self.c
        x1 = (-self.b + delta ** 0.5) / (2 * self.a)
        x2 = (-self.b - delta ** 0.5) / (2 * self.a)

        if delta == 0:
            print("方程有两个相同的解,x=", -self.b / (2 * self.a))
        elif delta < 0:
            print("原方程无实根。")
        else:
            print("方程有两个根分别为x1={:.2f},x2={:.2f}。".format(x1, x2))


if __name__ == '__main__':
    k1 = SolutionOfEqu()
    k1.input_()
    k1.quadratic()